package com.lggry.moviedemo;

import java.util.Scanner;

public class MovieOperator {

    private Moive[] moives; //记住一个电影对象的数组。
    private int count;

    public MovieOperator(Moive[] moives){
        this.moives = moives;
    }
    //打印所有的电影
    public void printAllMovie(){
        for(int i = 0;i < moives.length;i++){
            Moive item = moives[i];
            System.out.println(item.getId()+"\t"+item.getName()+"\t"+item.getPrice()+"\t"+item.getDirector());
        }
    }

    public void searchMovieById (){
        System.out.println("请输入要查询的电影编号：");
        Scanner scanner = new Scanner(System.in);
        int id = scanner.nextInt();
        for (int i = 0;i < moives.length;i++){
            Moive item = moives[i];
            if(item.getId() == id){
                System.out.println(item.getId()+"\t"+item.getName()+"\t"+item.getPrice()+"\t"+item.getDirector());
            }
        }
    }

}
